/*
 * QBigHugeWidget
 *
 * A widget demonstrating the BigHuge REST interface.
 *
 * Derived from QListView
 *
 * fetch() is used to retrieve synonyms from Big Huge.
 * Synonyms are displayed as checkboxes.
 *
 * getCheckedSynonyms() returns a QStringList of
 * synonyms which the user has checked.
 */

#ifndef QBIGHUGEWIDGET_H
#define QBIGHUGEWIDGET_H

#include <QWidget>
#include <QString>
#include <QStringList>
#include <QListView>
#include <QStandardItemModel>

#include "qbighuge.h"

class QLabel;

class QBigHugeWidget  : public QListView {
        Q_OBJECT

public:
        // no parent by default
        QBigHugeWidget(QWidget *parent = 0);

        // fetch synonyms from remote service
        void fetch(const QString& word) {
            bigHuge.fetchSynonyms(word);
        }

        // retrieve synonyms which the user has checked
        QStringList getCheckedSynonyms();

    public slots:
        void addSynonym(QString input);

private slots:
        // synonyms successfully downloaded
        void success(QStringList synonyms);
        // error occurred while fetching
        void failure(const QBigHuge::Error errorCode, const QString& errorString);

private:
        // BigHuge interface
        QBigHuge bigHuge;

        // data model
        QStandardItemModel model;
};

#endif // QBIGHUGEWIDGET_H
